<?php

declare(strict_types=1);

namespace Plugin\Attractions\Inspection\Model\Inspection_records;

use Hyperf\Database\Model\Relations\BelongsTo;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;
use Plugin\Attractions\Inspection\Model\Inspection_plans\InspectionPlans;
use Plugin\Attractions\Inspection\Model\Inspection_records_result\InspectionRecordsResult;

/**
 * @property int $id ID
 * @property int $plan_id 巡检计划ID
 * @property string $start_time 巡检开始时间
 * @property string $end_time 巡检结束时间
 * @property array $inspector 巡检人
 * @property string $remark 备注（可选）
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class InspectionRecords extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'inspection_records';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'plan_id', 'start_time', 'end_time', 'inspector', 'remark', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'plan_id' => 'integer', 'inspector' => 'array', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function result(): HasMany
    {
        return $this->hasMany(InspectionRecordsResult::class, 'inspection_record_id', 'id');

    }

    public function plan(): BelongsTo
    {
        return $this->belongsTo(InspectionPlans::class, 'plan_id', 'id');

    }
}
